import socket,time,os,select,struct
from base import *

con_outEth = 'enp1s0f2'

os.system('ovs-vsctl del-br br0')
os.system('ip tuntap del dev tap0 mod tap')


os.system('ovs-vsctl add-br br0')
os.system('ip tuntap add dev tap0 mod tap')
os.system('ip link set tap0 up')   

os.system('ovs-vsctl add-port br0 '+con_outEth)
os.system('ovs-vsctl add-port br0 tap0')



tap = openTap(b'tap0')
s = socket.socket()
add = ('127.0.0.1',19988)
#add = ('149.129.66.208',19988)
while True:
    try:
        s.connect(add)
        print('ok')
        break
    except:
        time.sleep(0.1)
s.setblocking(False)
work(s, tap)

    
    
